module test_signal;

private import dactor.scheduler;
private import dactor.coroutine;
private import dactor.eventlet;
private import dactor.log;
private import core.sys.posix.signal;
private import std.stdio;


void test_signal_term() {
    while (true) {
        SignalEvent ev = new SignalEvent(SIGTERM);
        int ret = ev.wait();
        logDebug("wait term signal result: %d", ret);
    }
}


void test_signal_int() {
    //SignalEvent ev = new SignalEvent(SIGINT, Event.PERSIST, 1000);
    while (true) {
        scope SignalEvent ev = new SignalEvent(SIGINT);
        int ret = ev.wait();
        logDebug("wait int signal result: %d", ret);
    }
}

void main() {
    writefln("This application will handle SIG_INT and SIG_TERM, press CTRL + '\\' to quit.");

    spawn(&test_signal_int);
    spawn(&test_signal_term);

    Scheduler.instance.run();
}

